package testdoc

import (
	"fmt"
	"jinquan.supor.com/common"
	"go.mongodb.org/mongo-driver/bson/primitive"
)

type UserDoc struct {
  //DocId: struct里面获取ObjectID, Document必须字段
  DocId     primitive.ObjectID `bson:"_id"`  
  UserId 		int
  Username 		string
  Password 		string
  Email  		string
  Hiredate 		string
  Regtime 		string
}


func AllocDoc() (Doc []interface{}) {
	Doc = append(Doc, UserDoc{
		DocId: primitive.NewObjectID(), 
		UserId: 0, 
		Username: "", 
		Password: "", 
		Email: "", 
		Hiredate: "", 
		Regtime: "",
	})
	return
}


func GenDocArray(N int) (Doc []interface{}) {
	var i int
		for i = 0; i < N; i++ {
			_Username := fmt.Sprintf("U%s", common.Srand(6, common.KC_RAND_KIND_NUM))
			_Email := fmt.Sprintf("%s@qq.com", _Username)
			Doc = append(Doc, UserDoc{
				DocId:     primitive.NewObjectID(),
				UserId:    common.Irand(100),
				Username:  _Username,
				Password:  common.Srand(16, common.KC_RAND_KIND_ALL),
				Email:     _Email,
				Hiredate:  fmt.Sprintf("2018-04-%d", common.Irand(31)),
				Regtime:   common.CurTime(),
			})
		}
	return
}
